//
//  MYStatus.swift
//  Sina
//
//  Created by 王亮龙1 on 16/5/24.
//  Copyright © 2016年 lianglong. All rights reserved.
//

import UIKit

class MYStatus: NSObject {
    
    //每一条网络信息都有自己唯一的id
    var id: Int64 = 0
    ///微博内容
    var text: String?
    ///发布时间
    var created_at: String?
    ///微博来源
    var source: String?
    ///用户信息
    var user: MYUser?
    ///转发微博
    var retweeted_status: MYStatus?
    ///图片数组
    var pic_urls: [MYStatusPicture]?
    ///转发数
    var reposts_count: Int = 0
    ///评论数
    var comments_count: Int = 0
    ///点赞数
    var attitudes_count: Int = 0

    
    
    init(dict: [String : AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        //用户信息字典
        if key == "user" {
            
            if let dict = value as? [String : AnyObject] {
                user = MYUser(dict: dict)
            }
            return
        }
        
        //转发微博字典
        if key == "retweeted_status" {
            
            if let dict = value as? [String : AnyObject] {
                retweeted_status = MYStatus(dict: dict)
            }
            return
        }
        
        //微博图片数组
        if key == "pic_urls" {
            if let array = value as? [[String : String]] {
                var tempArr = [MYStatusPicture]()
                for item in array {
                    let picture = MYStatusPicture(dict: item)
                    tempArr.append(picture)
                }
                pic_urls = tempArr
            }
            return
        }
        
        
        super.setValue(value, forKey: key)
    }
    
    //过滤
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }

}



